<?php namespace App\Http\Controllers\Site;

use App\Http\Controllers\Controller;
use App\Item;
use DB;
use Illuminate\Http\Request;

class SignupController extends Controller
{
    public function getIndex()
    {
        return view('site.Signup.index');
    }

    public function postSignup(Request $request){
        $data = $request->all();
        $student = new Item();
        $student->name = $data['name'];
        $student->type = 'student';
        $student->user_id = 2;
        $student->content = json_encode([
            'name'=>$data['name'],
            'sex'=>$data['sex'],
            'mobile'=>$data['mobile'],
            'qq' => $data['qq'],
            'course' => $data['course'],
            "addr"=> $data['addr'],
            "channel"=> $data['channel'],
            "messages"=> $data['messages'],
        ]);
        $result = $student->save();
        if($result){
            $res =  ['status'=>'success','message'=>'保存成功'];
        }else{
            $res =  ['status'=>'faile','message'=>'保存失败'];
        }
        return \Response::json($res);
    }
}